﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Cdn.Blogger.Models
{
    public enum ReportType
    {
        Error, Warning, Info, Success, Verbose
    }

    public class ReportLine
    {
        public string Message { get; set; }
        public ReportType MessageType { get; set; }
    }
    public class ReportData
    {
        Controller container;
        public ReportData(Controller control)
        {
            container = control;
        }

        bool visible = false;

        public bool Visible
        {
            get { return visible; }
            set
            {
                visible = value;
                NotifyParent();
            }
        }
        List<ReportLine> lines = new List<ReportLine>();

        public List<ReportLine> GetLines()
        {
            NotifyParent();
            return lines;
        }
        public ReportLine AddLine(string message, ReportType rType = ReportType.Success)
        {
            var rl = new ReportLine()
            {
                Message = message,
                MessageType = rType
            };
            lines.Add(rl);
            NotifyParent();
            return rl;
        }
        public void NotifyParent()
        {
            container.ViewBag.ReportData = this;
            container.ViewData["ReportData"] = this;
            container.TempData["ReportData"] = this;
        }
    }
}